﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Web.App.Infrastructure.ApplicationMessages.Contracts;
using Web.App.Infrastructure.ApplicationMessages.Implementation;

namespace Web.App.Infrastructure.ApplicationMessages.Builder
{
    public class BuildFailure
    {
        private object _attemptedValue = new object();
        private string _failureCode = "SomeFailurCode";
        private string _failureMessage = "SomeFailureMessage";
        private string _property = "SomeProperty";

        public BuildFailure WithAttemptedValue(object attemptedValue)
        {
            _attemptedValue = attemptedValue;
            return this;
        }

        public BuildFailure WithFailureCode(string failureCode)
        {
            _failureCode = failureCode;
            return this;
        }

        public BuildFailure WithFailureMessage(string failureMessage)
        {
            _failureMessage = failureMessage;
            return this;
        }

        public BuildFailure WithFailureProperty(string failureProperty)
        {
            _property = failureProperty;
            return this;
        }
        
        private Failure Build()
        {
            return new Failure(_attemptedValue,_failureCode, _failureMessage, _property);
        }

        public static implicit operator Failure(BuildFailure builder)
        {
            return builder.Build();
        }

        
    }
}